<template>
   <div id="app">
		<Nav v-if="!hideNav"></Nav>
        <div class="content">
            <router-view></router-view>
        </div>
    </div>
</template>
<script>
import Nav from "@/views/nav/index";
export default {
  data(){
    return{
    hideNav:false,
    hideNavArr:  ['login', 'register', 'forget','mycode',],
    }
  },
  watch: {
        $route (to, from) {
            // const userId = localStorage.getItem('userId');
            // let url = window.location.href;
            // if(!userId && url.indexOf('register') == -1 && url.indexOf('forget') == -1 && url.indexOf('download') == -1){
            //     this.$router.push({
            //         path: '/login'
            //     })
            // };
            if(this.hideNavArr.indexOf(to.name) >= 0){
                this.hideNav = true;
            }else{
                this.hideNav = false;
            }
            document.title = "钻石虚拟币平台";
        }
    },
  mounted() {
  let url =window.location.href
  // const userId = localStorage.getItem('userId')
  // if(userId && url.indexOf('register')==-1 && url.indexOf('forget') == -1){
  //   this.$router.push({
  //     path:'/login'
  //   })
  // };
  if(url.indexOf('register') == -1 && url.indexOf('forget') == -1 && url.indexOf('login') == -1 && url.indexOf('mycode') == -1 && url.indexOf('download') == -1){
            this.hideNav = false;
        }else{
            this.hideNav = true;
        }
        document.title = "钻石虚拟币平台";
    },
    components: {
		Nav
  }
}
</script>
<style lang="stylus">
body{
  margin 0;
  padding 0;
}
#nav
  padding 30px
  a
    font-weight bold
    color #2c3e50
    &.router-link-exact-active
      color #42b983
</style>
